package com.forest.core.etx

import android.content.Context
import android.net.Uri
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions

fun ImageView.circleCrop(context: Context, url: String, placeholder: Int) {
    val options = RequestOptions().circleCrop().error(placeholder).diskCacheStrategy(DiskCacheStrategy.NONE)
    load(context, url, options)
}

fun ImageView.load(context: Context, url: String?, options: RequestOptions) {
    Glide.with(context)
            .asBitmap()
            .load(url)
            .apply(options)
            .into(this)
}


fun ImageView.load(context: Context, url: String?) {
    Glide.with(context)
            .asBitmap()
            .load(url)
            .into(this)
}

fun ImageView.load(context: Context, resId: Int, options: RequestOptions) {
    Glide.with(context)
            .load(resId)
            .apply(options)
            .into(this)
}

fun ImageView.load(context: Context, uri: Uri) {
    Glide.with(context)
        .load(uri)
        .into(this)
}

fun ImageView.load(context: Context, uri: Uri, options: RequestOptions) {
    Glide.with(context)
        .load(uri)
        .apply(options)
        .into(this)
}